package com.cn.wanxi.servlet;

import com.cn.wanxi.model.CompanyModel;
import com.cn.wanxi.model.NavModel;
import com.cn.wanxi.model.NewsModel;
import com.cn.wanxi.service.CompanyService;
import com.cn.wanxi.service.NavService;
import com.cn.wanxi.service.NewsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/newsCenter")
public class NewsCenterServlet extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        /////////////////////////////////////////////////////////////////导航部分广告
        //导航会有六个不同的对象，然后一起发送到前端页面
        NavService navService = new NavService();
        ArrayList<NavModel> navModelList = navService.getNavModelListForHome();
        req.setAttribute("navModelList",navModelList);
        //java 的四大作用域
        //////////////////////////////////////////////////////////////公司信息
        CompanyService companyService = new CompanyService();
        CompanyModel companyModel = companyService.getCompanyModel();
        req.setAttribute("company",companyModel);
        ///////////////////////////////////////////////////////////底部公司信息
        CompanyModel companyModel5 = companyService.getCompanyModelbottom();
        req.setAttribute("company5",companyModel5);
        ////////////////////////////////////////////////////////////新闻中心上面大图
        CompanyModel companyModel2 = companyService.getNewsCompanyModel();
        req.setAttribute("companyModel2",companyModel2);
        ////////////////////////////////////////////////////////////得到新闻中心的导航
        ArrayList<NavModel> navModelList3 = navService.getNavModelListForNewsCenter();
        req.setAttribute("navModelList3",navModelList3);
        ///////////////////////////////////////////////////////////的到新闻中心新闻
        NewsService newsService = new NewsService();
        ArrayList<NewsModel> nawsModelList = newsService.getNewsModelListForNewsCenter();
        req.setAttribute("nawsModelList",nawsModelList);








        req.getRequestDispatcher("/jsp/newsCenter.jsp").forward(req,resp);
    }
}
